<?php

namespace app\service;

use app\ErrorCode;
use app\exception\ApiException;
use app\model\AdminRole;
use app\traits\Singleton;

class AdminRoleService
{

    use Singleton;
    public function createAdminRole($userId, $roleId)
    {
        $roleInfo = RoleService::getInstance()->getRoleById($roleId);
        if (!$roleInfo) {
            throw new ApiException("角色不存在", ErrorCode::BUSINESS);
        }
        return AdminRole::create([
            'admin_id' => $userId,
            'role_id' => $roleId
        ]);
    }
}
